package cn.tedu.eb_film.controller;

import cn.tedu.eb_film.pojo.dto.ServiceCinemaDto;
import cn.tedu.eb_film.pojo.dto.ServiceCinemaUpdateDto;
import cn.tedu.eb_film.pojo.entity.ServiceCinema;
import cn.tedu.eb_film.pojo.vo.ServiceCinemaVo;
import cn.tedu.eb_film.service.ServiceCinemaService;
import cn.tedu.eb_film.utils.JsonResult;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 服务表(CinemaService)表控制层
 *
 * @author zhaohaoyu
 * @since 2023-03-17
 */
@RestController
@RequestMapping("/CinemaService")
@Api(tags = "电影院服务")
public class CinemaServiceController {

  @Autowired
  ServiceCinemaService serviceCinemaService;

    /**
     * 添加新的电影院服务
     * @param serviceCinemaDto
     * @return
     */
    @PostMapping("/AddServiceCinema")
    public JsonResult AddCinemaService(ServiceCinemaDto serviceCinemaDto) {
        serviceCinemaService.AddCinemaService(serviceCinemaDto);
        return JsonResult.ok();
    }

    /**
     * 批量添加电影院服务
     * @param list
     * @return
     */
    @PostMapping("/AddServiceCinemaList")
    public JsonResult AddCinemaServiceList(List<ServiceCinema> list){
        serviceCinemaService.AddCinemaServiceList(list);
        return JsonResult.ok();
    }

    /**
     * 根据id删除电影院服务
     * @param id
     * @return
     */
    @PostMapping("/DeleteServiceCinemaById")
    public JsonResult DeleteCinemaServiceById(Long id){
        serviceCinemaService.DeleteCinemaServiceById(id);
        return JsonResult.ok();
    }

    /**
     * 根据ids删除服务
     * @param list
     * @return
     */
    @PostMapping("/DeleteServiceCinemaByIds")
    public JsonResult DeleteCinemaServiceById(List<Long> list){
        serviceCinemaService.DeleteCinemaServiceByIds(list);
        return JsonResult.ok();
    }

    /**
     * 统计服务
     * @return
     */
    @GetMapping("/CountServiceCinema")
    public JsonResult CountServiceCinema(){
        serviceCinemaService.CountServiceCinema();
        return JsonResult.ok();
    }

    /**
     * 根据id获取服务详情
     * @param id
     * @return
     */
    @PostMapping("/GetServiceCinemaById")
    public JsonResult<ServiceCinemaVo> GetServiceCinemaById(Long id){
        ServiceCinemaVo serviceCinemaVo = serviceCinemaService.GetServiceCinemaById(id);
        return JsonResult.ok(serviceCinemaVo);
    }

    /**
     * 获取服务集合
     * @return
     */
    @GetMapping("/GetServiceCinemaList")
    public JsonResult<List<ServiceCinemaVo>> GetServiceCinemaList(){
        List<ServiceCinemaVo> list = serviceCinemaService.GetServiceCinemaList();
        return JsonResult.ok(list);
    }



    @PostMapping("/updateServiceCinema")
    public JsonResult updateServiceCinema(ServiceCinemaUpdateDto serviceCinemaUpdateDto){
        serviceCinemaService.updateServiceCinema(serviceCinemaUpdateDto);
        return JsonResult.ok();
    }
}
